# @Time : 2023/1/4
# @Author : SDAJAVA

person = {'name': '张三', 'age': '12', 'sex': '男'}
# 查询
print(person['name'])
print(person['sex'])
print(person.get('name'))
print(person.get('tel'))

# 修改
person['name'] = '李四'
print(person)

# 添加
person['tel'] = '1378876553'
print(person)

# 删除
del person['age']
print(person)
# 删除整体字典
# del person
# 清空整个字典
# person.clear()
# print(person)

# 遍历
# 遍历字典的key
for key in person.keys():
    print(key)
# 遍历字典的value
for value in person.values():
    print(value)
# 遍历字典的key和value
for key, value in person.items():
    print(key, value)
# 遍历字典的项/元素
for item in person.items():
    print(item)